﻿using System.Data;

using DAL;
using Model;

namespace BLL
{
    public  class CommentBLL
    {
        public CommentBLL()
        { 
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Comment model)
        {
            //TODO: ADD  return EnterpriseUserDAL.Add(model);
            return CommentDAL.Add(model);
        }

        public DataSet GetCommentAll()
        {
            return CommentDAL.GetAllComment();
        }

        public DataSet GetCommentByDimension(string dimID)
        {
            return CommentDAL.GetCommentByDimension(dimID);
        }

        public DataSet GetCommentByPosition(string positionID)
        {
            return CommentDAL.GetCommentByPosition(positionID);
        }

        public DataSet GetCommentByReportPart(string reportID)
        {
            return CommentDAL.GetCommentByReportPart(reportID);
        }

        /// <summary>
        /// 获得指定的评语
        /// </summary>
        /// <param name="positionId">岗位ID</param>
        /// <param name="reportpartId">报告ID</param>
        /// <param name="regionId">区间ID</param>
        /// <param name="dimensionId">维度ID</param>
        /// <returns>评语字符串</returns>
        public string GetCommentByAll(int positionId, int dimensionId, int reportpartId, int regionId)
        {
            DataSet ds = CommentDAL.GetCommentByAll(positionId, dimensionId, reportpartId, regionId);
            if (ds == null || ds.Tables[0].Rows.Count == 0)
            {
                return string.Empty;
            }
            string commentString = ds.Tables[0].Rows[0]["comment_nm"].ToString();
            return commentString;
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Comment model)
        {
            CommentDAL.Update(model);
        }

        /// <summary>
        /// 删除岗位相关的所有评语
        /// </summary>
        /// <param name="posID">岗位ID</param>
        /// <returns>删除的评语条数</returns>
        public int DelAllComment(int posID)
        {
            return CommentDAL.DelAllComment(posID);
        }
    }
}